<template>
  <div class="ac-menu">
    <div class="menu-item">
      <span class="item" v-for="(item,index) in menu" :class="{'active': $route.fullPath.includes(item.tic)}" :key="index" @click="selectMenu(item, index)">{{item.name}}</span>
    </div>
  </div>
</template>
<script>
import { tracker } from 'lib/analytics'
export default {
  name: "headBar",
  computed: {
  },
  data () {
    return {
      currentIndex: 0,
      menu: [{
        name: '会员查询',
        path: '/vip/search',
        tic: '/vip/search'
      }, {
        name: '入会申请',
        path: '/vip/supplier/notice',
        tic: '/vip/supplier/'
      }, {
        name: '会员变更',
        path: '/vip/update',
        tic: '/vip/update'
      }]
    }
  },
  components: {
  },
  mounted () {
  },
  created () {
  },
  methods: {
    selectMenu (item, index) {
      console.log(tracker.getRoles())
      if (index == 1 && (!tracker.getRoles() || !tracker.getRoles().includes("1"))) {
        this.$router.push({ path: '/login', query: { role: 1, back: window.location.href } })
        return false
      }
      if (index == 2 && (!tracker.getRoles() || !tracker.getRoles().includes("2"))) {
        this.$router.push({ path: '/login', query: { role: 2, back: window.location.href } })
        return false
      }
      this.currentIndex = index
      this.$router.push({ path: item.path })
    }
  }
}

</script>

<style lang="scss">
</style>
